package storage

import (
	"data-process/config"
	"data-process/logger"
)

type Storage interface {
	Write(data <-chan map[string]interface{})
}

// StorageContext 写入
type StorageContext struct {
	storage Storage
}

func NewStorage(storage config.Storage, keys []string) *StorageContext {
	return &StorageContext{
		storage: NewStorageFile(storage.File.Path, storage.File.Name, keys),
	}
}

func (s *StorageContext) Do(data <-chan map[string]interface{}) {
	logger.Infof("消费端初始化完成，开始写入数据")
	s.storage.Write(data)
}
